<?php
if (isset($_POST) && $_POST != null) {
    Base::updateUserInfo($_POST);
}
?>
<div class="span8">
    <?php foreach ($user_info as $_user_info) { ?>
        <form method="post" class="form-horizontal">
            <legend>Thông tin cá nhân</legend>
            <div style="display: none" id="error" class="alert alert-error"></div>
            <div class="control-group">
                <label class="control-label">Email</label>
                <div class="controls">
                    <input type="hidden" id="id" name="id" value="<?php echo $_user_info["_id"] ?>">
                    <input type="text" disabled="" value="<?php echo $_user_info["email"] ?>" class="input-xlarge">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Active Code</label>
                <div class="controls">
                    <input type="text" disabled="" value="<?php echo $_user_info["activecode"] ?>" class="input-xlarge">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Họ và tên</label>
                <div class="controls">
                    <input id="fullname" name="fullname" type="text" value="<?php echo $_user_info["fullname"] ?>" class="input-xlarge">
                </div>
            </div>
            <div class="control-group">
                <?php
                $day = date("j", $_user_info["birthday"]);
                $month = date("n", $_user_info["birthday"]);
                $year = date("Y", $_user_info["birthday"]);
                ?>
                <label class="control-label">Ngày sinh</label>
                <select id="day" name="day" style="width: 90px; margin-left: 19px">
                    <option value="0">Ngày</option>
                    <?php for ($i = 1; $i <= 31; $i++) { ?>
                        <?php if ($i == $day) { ?>
                            <option selected="selected" value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } else { ?>
                            <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } ?>
                    <?php } ?>
                </select>
                <select id="month" name="month" style="width: 90px">
                    <option value="0">Tháng</option>
                    <?php for ($i = 1; $i <= 12; $i++) { ?>
                        <?php if ($i == $month) { ?>
                            <option selected="selected" value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } else { ?>
                            <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } ?>
                    <?php } ?>
                </select>
                <select id="year" name="year" style="width: 90px">
                    <option value="0">Năm</option>
                    <?php for ($i = 1997; $i >= 1900; $i--) { ?>
                        <?php if ($i == $year) { ?>
                            <option selected="selected" value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } else { ?>
                            <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php } ?>
                    <?php } ?>
                </select>
            </div>
            <div class="control-group">
                <label class="control-label">Giới tính</label>
                <div class="controls">

                    <input type="radio" <?php if ($_user_info["gender"] == 1) { ?>checked=""<?php } ?> value="1" name="gender">
                    Nam        
                    <input type="radio" <?php if ($_user_info["gender"] == 0) { ?>checked=""<?php } ?> value="0" name="gender">
                    Nữ            
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Điện thoại</label>
                <div class="controls">
                    <input type="text" value="<?php echo $_user_info["phone"] ?>" class="input-xlarge" name="phone" id="phone">
                    <!--<a class="btn" href="/member/verify">Xác thực</a>-->
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"></label>
                <div class="controls">
                    <a id="update-info" href="javascript:void(0);" class="btn btn-primary">Cập nhật</a>
                    <!--<button class="btn btn-inverse" type="submit">Cập nhật</button>-->
                </div>
            </div>
        </form>
    <?php } ?>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $('#update-info').click(function() {
            isChangeUserInfo('<?php echo DOMAIN ?>');
        });
        $('#phone').keydown(isNumbericOnly);
    });
</script>
